<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top"><Top></Top></div>
      <div class="bottom">
        <div class="bottom_left">
          <div class="tourist">
            <Tourist></Tourist>
          </div>
          <div class="sex">
            <Sex></Sex>
          </div>
          <div class="age">
            <Age></Age>
          </div>
        </div>
        <div class="center">
          <Map class="map"></Map>
          <Line class="line"></Line>
        </div>
        <div class="right">
          <Rank class="rank"></Rank>
          <Year class="year"></Year>
          <Counter class="counter"></Counter>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import Top from './components/top.vue'
import Tourist from './components/tourist.vue'
import Sex from './components/sex.vue'
import Age from './components/age.vue'
import Map from './components/map/map.vue'
import Line from './components/line.vue'
import Rank from './components/rank.vue'
import Year from './components/year.vue'
import Counter from './components/counter.vue'
let screen = ref()

onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}

function getScale(w = 1920, h = 1080) {
  let ww = window.innerWidth / w
  let hh = window.innerHeight / h
  return ww < hh ? ww : hh
}
</script>

<style lang="scss" scoped>
.container {
  width: 100vw;
  height: 100vh;
  background: url('./images/bg.png') no-repeat;
  background-size: cover;
  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    left: 50%;
    top: 50%;
    transform-origin: left top;
    .top {
      width: 100%;
      height: 40px;
    }
    .bottom {
      width: 100%;
      display: flex;
      flex-direction: row;

      height: calc(1080px - 40px);
      .right {
        margin-left: 40px;
        flex: 20%;
        display: flex;
        flex-direction: column;
        .year,
        .counter {
          flex: 1;
        }
        .rank {
          flex: 1.5;
        }
      }
      .bottom_left {
        padding-top: 10px;
        flex: 20%;
        display: flex;
        flex-direction: column;
        gap: 10px;
        .age,
        .sex {
          flex: 1;
        }
        .tourist {
          flex: 1.5;
        }
      }
      .center {
        flex: 60%;
        display: flex;
        flex-direction: column;
        .map {
          flex: 4;
        }
        .line {
          flex: 1;
        }
      }
    }
  }
}
</style>
